module lang.d.sts.expressions.dcommaexpression;

import lang.d.sts.expressions.dexpression;
import lang.d.visitors.dvisitor;

class DCommaExpression: DExpression {
    private DExpression[] myExpressions;

    public this(DExpression expr) {
        myExpressions = new DExpression[1];
        myExpressions[0] = expr;
    }

    public this() {
        myExpressions = new DExpression[0];
    }

    public DExpression[] getExpressions() {
        return myExpressions;
    }

    public DCommaExpression opCatAssign(DExpression expr) {
        myExpressions ~= expr;
        expr.setParent(this);
        return this;
    }

    public DCommaExpression opCatAssign(DCommaExpression expr) {
        foreach (exp; expr.myExpressions) {
            myExpressions ~= exp;
            exp.setParent(this);
        }
        return this;
    }

    override public void accept(DVisitor visitor) {
        visitor.visitCommaExpression(this);
    }
}
